load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")
load("@fbsource//tools/build_defs:rust_unittest.bzl", "rust_unittest")

oncall("scm_server_infra")

rust_library(
    name = "bonsai_globalrev_mapping",
    srcs = glob([
        "src/**/*.rs",
        "schemas/**/*.sql",
    ]),
    named_deps = {
        "bincode": "fbsource//third-party/rust:bincode-2",
    },
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:bytes",
        "fbsource//third-party/rust:thiserror",
        "fbsource//third-party/rust:tracing",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/memcache_stub:memcache",
        "//eden/mononoke/common/rendezvous:rendezvous",
        "//eden/mononoke/common/rust/caching_ext:caching_ext",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/bonsai_globalrev_mapping/if:bonsai_globalrev_mapping_thrift-rust",
        "//eden/mononoke/server/context:context",
        "//thrift/lib/rust:fbthrift",
    ],
)

rust_library(
    name = "globalrev_pushrebase_hook",
    srcs = glob([
        "globalrev_pushrebase_hook/**/*.rs",
    ]),
    autocargo = {"cargo_toml_dir": "globalrev_pushrebase_hook"},
    test_deps = [
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:rand",
        "fbsource//third-party/rust:tokio",
        "//common/rust/shed/borrowed:borrowed",
        "//common/rust/shed/facet:facet",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/blobstore:blobstore",
        "//eden/mononoke/features/pushrebase:pushrebase",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/repo_attributes/bonsai_globalrev_mapping:bonsai_globalrev_mapping",
        "//eden/mononoke/repo_attributes/bonsai_hg_mapping:bonsai_hg_mapping",
        "//eden/mononoke/repo_attributes/commit_graph/commit_graph:commit_graph",
        "//eden/mononoke/repo_attributes/filestore:filestore",
        "//eden/mononoke/repo_attributes/repo_blobstore:repo_blobstore",
        "//eden/mononoke/repo_attributes/repo_derived_data:repo_derived_data",
        "//eden/mononoke/repo_attributes/repo_identity:repo_identity",
        "//eden/mononoke/repo_factory:test_repo_factory",
        "//eden/mononoke/tests/utils:tests_utils",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        ":bonsai_globalrev_mapping",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/features/pushrebase:pushrebase_hook",
        "//eden/mononoke/mononoke_types:mononoke_types",
        "//eden/mononoke/repo_attributes/bookmarks:bookmarks",
        "//eden/mononoke/server/context:context",
    ],
)

rust_unittest(
    name = "bonsai_globalrev_mapping_test",
    srcs = glob(["test/**/*.rs"]),
    crate = "bonsai_globalrev_mapping_test",
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:assert_matches",
        ":bonsai_globalrev_mapping",
        "//common/rust/shed/fbinit:fbinit",
        "//common/rust/shed/fbinit:fbinit-tokio",
        "//eden/mononoke/common/rendezvous:rendezvous",
        "//eden/mononoke/common/rust/sql_ext:sql_ext",
        "//eden/mononoke/common/sql_construct:sql_construct",
        "//eden/mononoke/mercurial:mercurial_types-mocks",
        "//eden/mononoke/mononoke_macros:mononoke_macros",
        "//eden/mononoke/mononoke_types:mononoke_types-mocks",
        "//eden/mononoke/server/context:context",
    ],
)
